<!DOCTYPE html>
<html lang="zh-cmn-Hans">

<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta name="format-detection" content="telephone=no" />
    <link rel="stylesheet" href="../../static/mobile/default/css/layout.css?v=2" />
    <link rel="icon" type="image/png" href="../../static/favicon.ico" />
    <script src="../../static/js/jquery/jquery/2.1.4/jquery.min.js"></script>
    <script src="../../static/js/jquery/jquery.cookie.js"></script>
    <script src="../../static/mobile/default/js/page.js?v=1"></script>
    <title>提现方式 - 达漂亮</title>

    <link rel="stylesheet" href="../../static/mobile/default/css/wallet.css" />

</head>

<body>
    <div class="page takeOut">
        <div class="page-hd">
            <div class="header base-header bor-1px-b">
                <div class="header-left">
                    <a href="javascript:history.go(-1)" class="left-arrow"></a>
                </div>
                <div class="header-title">提现方式</div>
                <div class="header-right">
                    <!-- <a href=""></a> -->
                </div>
            </div>
        </div>

        <div class="page-bd">
            <div class="goodslist">
                <ul>


                </ul>
            </div>
        </div>
        <div class="addType fs32 color_w fw_b BGcolor_r">
            添加提现方式
        </div>
        <!-- 支付方式 -->
        <div class="model">
            <div class="modelBg"></div>
            <div class="modelContent" style="height:3.3rem;">
                <div class="closeBox"><img src="../../static/mobile/default/images/close_icon.png" alt=""></div>
                <div class="title fs36 color_3 fw_b">请选择账号类型</div>
                <div class="cantre">
                    <label for="s12">
              <div class="block">
                  <div class="payType"><img src="../../static/mobile/default/images/offlinePay.png" alt=""><div><span class="fs30 color_3">银行卡账号</span></div></div>                         
                  <div class="iconBox">
                    <input type="radio" class="check" name="radiobox" id="s12">
                    <i class="icon_checked"></i>
                  </div>
                </div>
            </label>
                    <label for="s13">
              <div class="block">
                  <div class="payType"><img src="../../static/mobile/default/images/AliPay.png" alt=""><div><span class="fs30 color_3">支付宝账号</span></div></div>                          
                  <div class="iconBox">
                    <input type="radio" class="check" name="radiobox" id="s13" >
                    <i class="icon_checked"></i>
                  </div>                          
              </div>
			</label>
                    <label for="s14">
				<div class="block">
					<div class="payType"><img src="../../static/mobile/default/images/weixinPay.png" alt="">
						<div><span class="fs30 color_3">微信收款码</span></div>
					</div>
					<div class="iconBox">
						<input type="radio" class="check" name="radiobox" id="s14">
						<i class="icon_checked"></i>
					</div>
				</div>
			</label>
                </div>
            </div>
        </div>

    </div>

    <script type="text/html" id="liTpl">
        {{if list != ''}} {{each list as item index}}
        <li>
            <object>
              <div class="checkbox">
                <div class="block">
                  <div class="info">
                  {{if item.type == 'bank'}}
                    <div class="left"><img src="../../static/mobile/default/images/{{item.bank_code}}Bank.png" alt=""><span class="fs32 color_3 fw_b">{{item.bank_name}}</span></div>
                    <img src="../../static/mobile/default/images/rightIcon.png" alt="" class="rightIcon">
                    </div>
                    <div class="cardCode">
                        <label class="fs28 color_9">
                            <input style="width:0.2rem;" {{if item.is_receive == 1}}checked{{/if}} class="is_receive" nama="is_receive" type="checkbox" onclick="receive(this)" value="{{item.account_id}}">&nbsp;线下收款&nbsp;&nbsp;
                        </label>
                        <label class="fs28 color_9">
                            <input type="radio" name="is_default" {{if item.is_default == 1}}checked{{/if}} class="is_default" onclick="defaultid(this)" value="{{item.account_id}}">&nbsp;{{if item.account_ids > 0}}选择提现{{else}}提现默认{{/if}}
                        </label>
                    </div>
                    <div class="cardCode"><p class="fs38 color_3 num">{{item.bank_card_number}}</p><span class="fs28 color_9 fw_b">{{item.bank_cardholder}}</span></div>
                  {{else if item.type == 'alipay'}}
                  <div class="left"><img src="../../static/mobile/default/images/AliPay.png" alt=""><span class="fs32 color_3 fw_b">支付宝</span></div>
                    <img src="../../static/mobile/default/images/rightIcon.png" alt="" class="rightIcon">
                    </div>
                    <div class="cardCode">
                        <label class="fs28 color_9">
                            <input style="width:0.2rem;" {{if item.is_receive == 1}}checked{{/if}} class="is_receive" nama="is_receive" type="checkbox" onclick="receive(this)" value="{{item.account_id}}">&nbsp;线下收款&nbsp;&nbsp;
                        </label>
                    </div>
                    <div class="cardCode">
                        <p class="fs38 color_3 num">{{item.alipay_account}}</p><span class="fs28 color_9 fw_b">{{item.alipay_user_name}}</span>
                    </div>
                {{else}}
                  <div class="left"><img src="../../static/mobile/default/images/weixinPay.png" alt=""><span class="fs32 color_3 fw_b">微信</span></div>
                    <img src="../../static/mobile/default/images/rightIcon.png" alt="" class="rightIcon">
                    </div>
                    <div class="cardCode">
                        <label class="fs28 color_9">
                            <input style="width:0.2rem;" {{if item.is_receive == 1}}checked{{/if}} class="is_receive" nama="is_receive" type="checkbox" onclick="receive(this)" value="{{item.account_id}}">&nbsp;线下收款&nbsp;&nbsp;
                        </label>
                    </div>
                    <div class="cardCode"><p class="fs38 color_3 num">
                        </p><span class="fs28 color_9 fw_b">{{item.alipay_user_name}}</span>
                    </div>
                  {{/if}}
                </div>
                <div class="swiped BGcolor_3">
                  <div class="delect" data-account_id="{{item.account_id}}"><img src="../../static/mobile/default/images/delectIcon.png" alt=""></div>
                </div>
              </div>
            </object>
        </li>
        {{/each}} {{else}}
        <div style="text-align: center;-webkit-box-flex: 1;-webkit-flex: 1; font-size: 0.213333rem;white-space: nowrap;overflow: hidden;font-weight: bold;">暂无提现方式，请点击下方按钮添加</div>
        {{/if}}
    </script>

    </div>

    <script src="../../static/js/art-template.js"></script>
    <script src="../../static/mobile/default/js/lib/fastclick.js"></script>
    <script src="../../static/js/jquery/lazyload/jquery.lazyload.js"></script>
    <script>
        $(function() {
            FastClick.attach(document.body);
            $("img.lazy").lazyload({
                effect: "fadeIn",
                event: "scroll",
                container: $(".page-bd")
            });
        });
    </script>

    <script>
        var account_id = "45";
        var number = "";
        if (account_id > 0) {
            $('.left-arrow').attr('href', '/user/user/withdraw.html?number=' + number + '&account_id=' + account_id + '');
        } else {
            $('.left-arrow').attr('href', '/member/center/index.html')
        }


        //选择线下收款账户
        function receive(obj) {
            let num = 0;
            let ids = [];
            $('.is_receive').each(function() {
                if ($(this).is(":checked")) {
                    ids.push($(this).val());
                    num++;
                }
            })
            if (num >= 4) {
                _alert('最多可选择3个作为线下收款账户.');
                $(obj).attr("checked", false);
                return;
            }
            jq_ajax('/member/api.withdraw/updatepaytype.html', {
                ids: ids,
                field: 'is_receive'
            }, function(res) {
                if (res.code == 0) {
                    _alert(res.errmsg);
                    return false;
                }
            });
        }
        //设置默认提现账户
        function defaultid(obj) {
            let num = 0;
            let ids = $(obj).val();
            jq_ajax('/member/api.withdraw/updatepaytype.html', {
                ids: ids,
                field: 'is_default'
            }, function(res) {
                if (res.code == 0) {
                    _alert(res.errmsg);
                    return false;
                } else {
                    account_id = ids;
                    window.location.href = '/user/user/withdraw.html?number=' + number + '&account_id=' + account_id + '';
                }
            });
        }


        $(function() {

            share()

            function share() {
                /***用户点击分享到微信圈后加载接口接口*******/
                var url = window.location.href;
                console.log("url:" + url);
                $.ajax({
                    url: "/api/mp/wxconfig",
                    type: "get",
                    data: {
                        shareUrl: url
                    },
                    headers: {
                        token: $.cookie('code')
                    },
                    dataType: "json",
                    success: function(data) {
                        wx.config({
                            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参
                            //数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                            appId: data.data.appId, // 必填，公众号的唯一标识
                            timetamp: data.data.timetamp, // 必填，生成签名的时间戳
                            nonceStr: data.data.nonceStr, // 必填，生成签名的随机串
                            signature: data.data.signature, // 必填，签名，生成规则见微信公众号开发文档附录1
                            jsApiList: ['hideOptionMenu']
                        });
                        wx.ready(function() {
                            //ready会在config信息验证后执行，所有接口调用都必须在config接口获得结果后。
                            wx.hideOptionMenu({
                                success: function(res) {


                                },
                                fail: function(res) {

                                },
                            });
                        });
                    },
                    error: function() {
                        // 			_alert('ajax request failed!!!!');
                        return;
                    }
                })

            }

            $('.addType').on('click', function() {
                $('.model').show();
            })
            $('.closeBox').on('click', function() {
                $('.model').hide();
            })
            $('.model label').on('click', function() {
                    var index = $(this).index();
                    if (index == 0) {
                        window.location.href = '/member/withdraw/bankadd.html?account_id=' + account_id + '&number=' + number
                    } else if (index == 1) {
                        window.location.href = '/member/withdraw/alipayadd.html?account_id=' + account_id + '&number=' + number
                    } else if (index == 2) {
                        window.location.href = '/member/withdraw/weixinadd.html?account_id=' + account_id + '&number=' + number
                    }
                })
                //加载列表
            jq_ajax('/member/api.withdraw/getlist.html', '', function(res) {
                if (res.code == 0) {
                    _alert(res.errmsg);
                    return false;
                }
                for (let index = 0; index < res.list.length; index++) {
                    res.list[index]['account_ids'] = account_id;
                }
                $('.goodslist ul').html(template('liTpl', res));
                container();
            });
            //删除
            $('.goodslist').on('click', '.delect', function() {
                var obj = $(this);
                jq_ajax('/member/api.withdraw/delaccount.html', 'account_id=' + obj.data('account_id'), function(res) {
                    if (res.code == 0) {
                        _alert(res.errmsg);
                        return false;
                    }
                    obj.parents('li').remove();
                });
            })
        })

        function container() {
            //侧滑显示删除按钮
            var expansion = null; //是否存在展开的list
            var container = document.querySelectorAll('.goodslist object');
            for (var i = 0; i < container.length; i++) {
                var x, y, X, Y, swipeX, swipeY;
                container[i].addEventListener('touchstart', function(event) {
                    x = event.changedTouches[0].pageX;
                    y = event.changedTouches[0].pageY;
                    swipeX = true;
                    swipeY = true;
                    if (expansion) { //判断是否展开，如果展开则收起
                        expansion.className = "";
                    }
                });
                container[i].addEventListener('touchmove', function(event) {

                    X = event.changedTouches[0].pageX;
                    Y = event.changedTouches[0].pageY;
                    // 左右滑动
                    if (swipeX && Math.abs(X - x) - Math.abs(Y - y) > 0) {
                        // 阻止事件冒泡
                        event.stopPropagation();
                        if (X - x > 1) { //右滑
                            event.preventDefault();
                            this.className = ""; //右滑收起
                        }
                        if (x - X > 1) { //左滑
                            event.preventDefault();
                            this.className = "swipeleft"; //左滑展开
                            expansion = this;
                        }
                        swipeY = false;
                    }
                    // 上下滑动
                    if (swipeY && Math.abs(X - x) - Math.abs(Y - y) < 0) {
                        swipeX = false;
                    }
                });
                container[i].addEventListener('touchend', function(event) {
                    event.stopPropagation();
                });
            }
        }
    </script>

    <div class="alertBox">
        <div class="alertBG"></div>
        <div class="alert">
            <div class="text fs30 color_3 bor_b">

            </div>
            <!-- 单按钮 -->
            <div class="button fs32 fw_b color_r">
                知道了
            </div>
            <!-- 双按钮 -->
            <div class="buttonBox fs32 fw_b">
                <span class="color_9 bor_r cancel">取消</span>
                <span class="color_r confirm">确定</span>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var is_xcx = 0;
        $(document).on('click', 'a', function() {
            var href = $(this).attr('href');
            if (href.indexOf('/pages') != -1) {
                if (is_xcx == 1) {
                    wx.miniProgram.navigateTo({
                        url: href
                    })
                    return false;
                } else {
                    return false;
                }
            }
        })
    </script>
</body>

</html>